﻿using NaturalSort.Extension;

static void BiSearch()
{
    List<int> sortedList = new List<int> { 1, 3, 5, 7, 9 };
    int newItem = 6;

    int index = sortedList.BinarySearch(newItem);
    if (index < 0) index = ~index;

    sortedList.Insert(index, newItem);
    Console.WriteLine(String.Join(", ",sortedList));
}
// BiSearch();


static void UseListExt()
{
    List<int> sortedList = new List<int> { 1, 3, 5, 7, 9 };
    int newItem = 6;

    sortedList.AddSorted(newItem);

    Console.WriteLine(String.Join(", ",sortedList));
}
// UseListExt();

static void UseListExtNat()
{
    List<string> sortedList = new List<string> { "1", "10", "13", "15", "3" };
    IComparer<string> comparer=StringComparison.OrdinalIgnoreCase.WithNaturalSort();
    sortedList=sortedList.OrderBy(x=>x,comparer).ToList();
    string newItem = "2";
    sortedList.InsertIntoSortedList(newItem, comparer.Compare);

    Console.WriteLine(String.Join(", ",sortedList));
}
UseListExtNat();
Console.WriteLine("Hello, World!");
